/**
 * 官方文档：URL_ADDRESS * 官方文档：https://www.football-data.org/documentation
/**
 * 官方文档：URL_ADDRESS.football-data.org/documentation/quickstart
 * 注册获取有效key：URL_ADDRESS
 * 注册获取有效key：https://www.football-data.org/client/register
 */
import axios from 'axios'

const API_CONFIG = {
    baseURL: 'https://api.football-data.org/v4',
    headers: {
        'X-Auth-Token': 'ac73d8fd18b94d95ba13b43e4aa12c6d' // 注册获取有效key
    }
}

export async function fetchLeagueTeams(leagueCode = 'CSL') {
    try {
        const response = await axios.get(
            `/competitions/${leagueCode}/teams`,
            API_CONFIG
        )
        return response.data.teams.map(team => ({
            name: team.name,
            logo: team.crest
        }))
    } catch (error) {
        console.error('获取球队数据失败:', error)
        return []
    }
}